Karura

Row

Components of Total Value Locked

Row

Overall Total Value Locked (TVL)

  • The Overall TVL in the table below does not includes the Crowdloan TVL, which also seems to be the case on the stats.Karura.network page.
Date Block dexTVL bridgeTVL liquidStakingTVL crowdloanTVL LPTokenStakingTVL stableCoinTVL OverallTVL
2021-12-30 1,216,792 28,477,809 51,134,081 0 140,764,558 25,507,570 30,569,447 135,688,908
2021-12-31 1,223,729 27,960,331 48,351,235 0 139,511,714 25,103,934 28,130,859 129,546,358
2022-01-01 1,230,690 28,936,720 49,930,895 0 143,766,372 26,160,725 28,862,133 133,890,473
2022-01-02 1,237,666 28,994,199 51,315,701 0 147,915,792 26,526,360 29,765,768 136,602,028
2022-01-03 1,244,636 28,394,734 50,409,234 0 145,229,694 26,154,090 28,808,841 133,766,899
2022-01-04 1,251,539 28,279,294 52,019,213 0 150,381,390 26,588,509 19,511,557 126,398,574
2022-01-05 1,258,602 27,314,933 44,394,638 17,723,365 132,711,276 24,319,899 25,764,959 139,517,793
2022-01-06 1,265,574 26,758,257 45,074,353 17,710,566 135,913,545 24,795,243 26,374,687 140,713,108
2022-01-07 1,272,463 26,061,882 42,014,831 16,477,194 127,063,454 23,539,056 24,655,919 132,748,882
2022-01-08 1,279,512 24,834,724 40,087,529 15,777,941 120,914,495 22,439,016 23,320,806 126,460,016
2022-01-09 1,286,513 24,276,416 41,015,465 16,224,592 123,710,843 22,266,997 23,863,867 127,647,337
2022-01-10 1,293,438 23,718,700 39,980,105 15,865,354 120,252,993 21,399,214 23,289,506 124,252,880
2022-01-11 1,300,364 24,179,221 40,908,582 14,949,413 130,130,417 22,158,239 23,500,400 125,695,855
2022-01-12 1,307,287 25,224,845 43,333,388 16,031,649 138,263,881 23,105,439 24,877,177 132,572,497
2022-01-13 1,314,250 24,947,366 42,311,230 15,588,045 134,655,690 22,638,589 24,798,264 130,283,494
2022-01-14 1,321,145 25,197,576 44,074,088 16,310,065 140,874,808 23,229,692 25,251,168 134,062,589
2022-01-15 1,327,988 25,173,731 44,632,576 16,610,581 143,741,316 23,265,937 25,720,836 135,403,662
2022-01-16 1,334,836 24,928,016 42,887,794 15,933,003 138,649,757 22,758,043 24,757,053 131,263,909
2022-01-17 1,341,616 24,961,950 39,933,108 14,793,150 128,932,698 22,373,260 22,990,965 125,052,433
2022-01-18 1,348,556 24,818,429 41,763,928 14,731,644 127,815,161 22,260,949 22,932,495 126,507,444
2022-01-19 1,355,482 24,389,176 40,675,199 14,189,131 123,004,239 21,736,572 22,172,875 123,162,954
2022-01-20 1,362,368 24,053,310 38,238,798 14,140,066 122,392,851 21,465,155 22,542,280 120,439,610
2022-01-21 1,369,220 20,551,211 32,739,285 12,780,374 107,393,801 18,864,510 20,114,175 105,049,555
2022-01-22 1,376,066 16,317,883 28,167,143 11,865,142 94,439,392 16,607,242 17,473,724 90,431,134
2022-01-23 1,382,988 16,849,199 28,607,262 11,980,949 94,935,519 16,828,061 17,867,771 92,133,241
2022-01-24 1,389,889 14,899,662 27,129,450 11,315,066 87,298,181 15,616,499 16,469,949 85,430,625
2022-01-25 1,396,806 17,827,278 26,446,093 11,103,209 86,461,281 17,622,323 15,477,409 88,476,311
2022-01-26 1,403,696 16,977,302 24,928,536 10,568,643 82,532,362 16,721,750 14,509,393 83,705,624
2022-01-27 1,410,563 16,130,280 24,184,604 10,573,141 81,043,983 15,549,894 14,142,683 80,580,602
2022-01-28 1,417,498 16,380,471 25,439,407 11,004,982 84,592,037 16,104,994 14,880,991 83,810,844
2022-01-29 1,424,433 16,530,233 25,580,442 11,160,147 85,784,745 16,445,727 15,030,737 84,747,286
2022-01-30 1,431,336 16,734,485 24,540,561 10,700,703 82,116,417 16,243,530 14,737,654 82,956,932
2022-01-31 1,438,201 16,430,659 24,495,023 10,668,834 82,341,929 16,197,197 14,557,891 82,349,604
2022-02-01 1,445,158 16,888,402 25,635,766 11,034,229 86,486,338 16,914,252 15,404,398 85,877,048
2022-02-02 1,452,085 16,385,550 23,913,238 10,349,332 81,214,369 16,052,553 14,365,291 81,065,964
2022-02-03 1,459,034 16,206,473 23,722,177 10,278,882 80,562,891 15,956,459 14,217,673 80,381,663
2022-02-04 1,465,910 17,573,369 26,122,753 11,391,759 89,282,686 17,121,034 15,827,834 88,036,748
2022-02-05 1,472,341 18,115,769 27,078,583 11,849,538 92,805,684 17,713,412 16,398,245 91,155,546
2022-02-06 1,478,495 18,433,454 28,217,628 12,416,470 97,155,559 18,154,593 16,889,128 94,111,273
2022-02-07 1,484,572 18,710,293 28,793,182 12,616,948 99,906,804 18,267,154 17,157,854 95,545,431
2022-02-08 1,489,375 18,120,633 27,602,820 12,049,255 95,491,781 17,472,360 16,186,674 91,431,741
2022-02-09 1,493,799 18,398,595 28,125,621 12,480,553 97,165,581 17,803,463 16,525,057 93,333,290
2022-02-10 1,498,135 18,252,209 28,034,357 13,414,151 90,680,860 17,663,953 16,628,704 93,993,374
2022-02-11 1,502,412 17,183,038 25,318,045 12,137,702 81,730,541 16,404,820 15,073,577 86,117,181
2022-02-12 1,506,675 16,523,389 25,340,756 12,182,443 83,118,693 15,821,602 15,213,651 85,081,841
2022-02-13 1,510,965 16,142,836 25,398,301 12,321,765 82,176,554 15,494,594 15,517,512 84,875,008
2022-02-14 1,515,339 15,758,810 25,800,264 12,471,674 83,664,933 15,259,547 15,557,219 84,847,514
2022-02-15 1,519,779 16,270,303 26,785,512 13,000,873 87,273,124 15,663,195 16,107,445 87,827,329
2022-02-16 1,524,208 16,060,289 25,561,909 12,573,172 84,316,412 15,417,258 15,537,487 85,150,115
2022-02-17 1,528,534 15,144,082 23,726,986 11,718,180 78,222,578 14,445,991 14,190,604 79,225,843
2022-02-18 1,532,831 14,556,699 22,197,937 11,201,867 74,428,966 13,954,505 13,518,494 75,429,502
2022-02-19 1,537,082 14,233,537 22,341,383 11,320,339 74,905,046 13,747,935 13,445,019 75,088,213
2022-02-20 1,541,290 13,366,110 21,185,914 10,655,435 70,229,432 12,813,940 12,490,299 70,511,699
2022-02-21 1,545,293 12,628,156 19,536,563 9,792,882 64,326,030 12,086,393 12,830,700 66,874,694
2022-02-22 1,549,212 11,534,618 19,525,296 9,860,940 64,862,248 11,070,438 12,685,919 64,677,212
2022-02-23 1,553,133 11,597,913 18,744,439 9,445,214 62,075,922 11,039,039 12,841,973 63,668,578
2022-02-24 1,557,141 10,531,902 17,536,389 8,915,579 58,402,583 10,108,575 12,117,829 59,210,274
2022-02-25 1,561,208 10,855,034 18,837,499 9,614,395 62,887,765 10,661,756 13,064,856 63,033,540
2022-02-26 1,565,186 10,921,496 19,109,865 9,770,904 64,185,712 10,696,326 13,078,500 63,577,091
2022-02-27 1,569,198 10,116,662 17,441,119 8,984,982 58,898,709 9,913,956 12,057,255 58,513,974
2022-02-28 1,573,192 10,479,921 18,930,295 9,695,624 64,506,440 10,482,123 13,051,277 62,639,240
2022-03-01 1,577,360 10,879,012 20,196,726 10,451,229 69,793,442 10,889,494 14,094,592 66,511,053
2022-03-02 1,581,658 10,743,363 20,126,523 10,443,673 69,763,374 10,776,685 13,957,452 66,047,695
2022-03-03 1,586,008 10,431,306 18,990,177 9,884,753 65,944,705 10,385,361 13,403,247 63,094,845
2022-03-04 1,590,339 9,792,560 17,465,894 9,086,777 60,311,918 9,643,278 12,258,298 58,246,807
2022-03-05 1,594,558 9,823,524 17,884,062 9,309,293 61,619,887 9,727,515 12,338,275 59,082,669
2022-03-06 1,598,920 9,881,613 17,885,512 9,327,350 61,685,035 9,787,879 12,547,580 59,429,935
2022-03-07 1,603,233 9,684,250 17,326,846 9,069,358 59,986,178 9,488,150 11,954,912 57,523,515
2022-03-08 1,607,573 9,699,877 17,932,807 9,387,102 60,737,885 9,573,868 12,157,986 58,751,640
2022-03-09 1,611,910 10,236,962 19,725,994 10,343,541 67,117,367 10,225,894 13,544,592 64,076,982
2022-03-10 1,616,357 9,900,504 18,299,797 9,634,859 62,842,663 9,773,595 12,491,199 60,099,955
2022-03-11 1,620,876 9,938,713 18,462,794 9,726,906 62,496,878 9,744,618 12,326,243 60,199,273
2022-03-12 1,625,432 9,937,874 18,441,732 9,895,685 62,301,434 9,759,643 8,778,466 56,813,400
2022-03-13 1,629,884 9,582,229 18,116,132 9,700,675 61,218,977 9,568,388 11,976,980 58,944,404
2022-03-14 1,634,405 9,517,275 17,795,026 9,596,841 59,835,837 9,434,480 11,662,586 58,006,208
2022-03-15 1,638,930 9,610,346 18,506,925 9,986,903 62,476,832 9,569,630 12,033,881 59,707,686
2022-03-16 1,643,457 9,916,992 19,246,131 10,344,356 64,857,236 9,892,838 12,611,340 62,011,656
2022-03-17 1,647,983 10,164,252 19,882,115 10,758,928 67,488,209 10,151,956 13,177,318 64,134,570
2022-03-18 1,652,652 10,723,778 21,763,378 11,811,109 74,028,055 10,815,317 14,620,780 69,734,362
2022-03-19 1,657,396 10,857,718 21,697,651 11,760,488 73,587,054 10,793,818 14,630,661 69,740,336
2022-03-20 1,662,219 10,805,099 22,069,929 12,004,244 75,235,797 10,790,571 14,435,960 70,105,804
2022-03-21 1,666,997 10,821,370 22,461,272 12,289,184 77,490,917 10,765,845 14,920,932 71,258,603
2022-03-22 1,671,509 10,996,672 22,945,241 12,586,513 79,074,512 10,972,353 15,076,643 72,577,421
2022-03-23 1,675,850 11,233,620 23,583,433 13,062,818 82,221,656 11,139,196 15,709,358 74,728,425
2022-03-24 1,680,082 11,210,552 23,562,119 13,021,250 81,961,065 11,102,612 15,926,435 74,822,967
2022-03-25 1,684,322 11,178,468 23,689,405 13,123,045 82,517,327 11,064,343 15,906,943 74,962,205
2022-03-26 1,688,574 11,229,645 23,533,482 13,049,274 82,607,532 11,065,482 15,887,907 74,765,789
2022-03-27 1,692,713 12,008,614 24,954,498 13,815,147 87,157,862 11,906,857 17,345,787 80,030,904
2022-03-28 1,696,873 11,865,913 24,656,797 13,634,351 86,130,530 11,777,602 17,079,663 79,014,326
2022-03-29 1,700,908 12,430,365 26,011,354 14,389,203 91,031,656 12,273,067 17,897,927 83,001,915
2022-03-30 1,704,922 12,650,038 27,215,507 15,121,153 94,504,540 12,455,690 18,441,788 85,884,175
2022-03-31 1,708,906 12,971,828 27,453,575 15,209,696 94,975,610 12,736,756 19,092,108 87,463,963
2022-04-01 1,712,970 12,900,127 27,266,240 15,225,084 95,055,792 12,674,707 18,957,801 87,023,959
2022-04-02 1,717,078 13,877,724 29,392,612 16,411,345 102,197,003 13,890,553 20,648,204 94,220,438
2022-04-03 1,721,276 13,765,513 28,762,687 16,147,422 100,488,124 13,538,763 20,101,758 92,316,143
2022-04-04 1,725,277 13,113,962 26,814,870 14,834,897 94,544,631 13,011,853 18,544,418 86,320,000
2022-04-05 1,729,249 12,982,728 25,909,704 14,361,013 91,056,713 12,918,024 18,129,594 84,301,063
2022-04-06 1,733,105 12,388,690 24,751,557 13,757,432 86,887,248 12,343,894 17,126,109 80,367,681
2022-04-07 1,736,920 12,192,261 25,924,313 14,445,681 90,901,360 11,991,153 19,099,672 83,653,079
2022-04-08 1,740,728 11,748,502 24,358,316 13,690,735 86,235,769 11,243,280 17,863,594 78,904,427
2022-04-09 1,744,511 11,679,970 25,159,437 14,129,747 89,012,072 11,394,509 17,970,468 80,334,132
2022-04-10 1,748,342 11,992,406 24,402,148 13,629,715 86,250,803 11,536,706 18,709,034 80,270,010
2022-04-11 1,752,148 10,613,556 21,942,010 12,131,417 76,819,392 10,171,332 15,794,129 70,652,445
2022-04-12 1,756,009 10,807,351 21,779,978 12,208,892 76,919,620 10,284,334 15,777,556 70,858,110
2022-04-13 1,759,810 11,088,597 22,767,525 12,792,713 80,051,730 10,505,451 16,804,316 73,958,602
2022-04-14 1,763,619 11,029,818 22,969,648 12,946,382 80,337,379 10,478,740 16,752,968 74,177,556
2022-04-15 1,767,375 11,234,948 23,770,221 13,410,938 82,893,181 10,788,714 17,192,776 76,397,598
2022-04-16 1,771,087 11,528,819 25,046,710 14,131,118 87,253,078 11,210,479 18,011,711 79,928,836
2022-04-17 1,774,902 11,432,100 25,067,937 13,960,079 86,220,735 11,083,865 18,250,198 79,794,178
2022-04-18 1,778,708 11,255,844 24,272,117 13,882,331 83,644,887 10,805,322 16,554,502 76,770,115
2022-04-19 1,782,472 11,267,515 25,774,203 14,713,377 88,576,082 11,130,608 17,592,326 80,478,028
2022-04-20 1,786,343 11,377,126 26,241,715 15,042,279 90,385,189 11,009,850 18,213,130 81,884,101
2022-04-21 1,790,294 11,532,164 24,862,952 14,142,810 83,995,684 11,047,198 18,110,831 79,695,954
2022-04-22 1,794,197 11,731,877 24,569,432 14,117,181 82,407,077 11,439,832 18,008,727 79,867,048
2022-04-23 1,798,162 12,038,829 25,192,159 15,293,481 82,231,679 11,376,034 19,281,727 83,182,229
2022-04-24 1,802,115 11,786,301 24,391,592 14,807,685 80,217,106 11,147,580 19,199,526 81,332,684
2022-04-25 1,806,087 11,986,409 24,965,430 15,201,526 81,966,076 11,064,717 19,705,764 82,923,846
2022-04-26 1,810,046 11,595,769 23,489,920 14,400,527 77,330,553 10,617,280 18,674,336 78,777,832
2022-04-27 1,814,021 11,456,731 23,866,785 14,702,543 78,793,875 10,662,643 18,695,554 79,384,256
2022-04-28 1,817,974 11,458,940 23,752,925 14,663,300 78,598,431 10,806,233 18,558,400 79,239,799
2022-04-29 1,821,980 10,877,984 21,887,982 13,414,234 73,110,973 10,096,881 17,325,218 73,602,298
2022-04-30 1,826,039 10,135,613 19,670,509 12,055,765 65,568,852 9,352,427 15,469,289 66,683,603
2022-05-01 1,830,125 10,191,535 20,056,144 12,283,977 66,691,400 9,500,086 15,730,769 67,762,511
2022-05-02 1,834,044 10,045,055 19,877,550 12,229,399 65,513,727 9,441,725 15,789,105 67,382,835
2022-05-03 1,837,991 9,940,595 19,438,387 11,951,408 63,910,086 9,303,836 15,530,323 66,164,548
2022-05-04 1,841,986 10,332,852 21,486,168 13,203,540 70,359,728 9,675,387 16,898,031 71,595,977
2022-05-05 1,846,132 9,849,962 19,537,458 12,007,333 63,824,893 9,040,416 15,858,555 66,293,723
2022-05-06 1,850,190 9,840,823 19,689,475 12,050,273 63,484,119 9,080,372 15,831,354 66,492,296
2022-05-07 1,854,421 9,415,404 18,000,461 11,169,970 58,848,596 8,701,207 14,431,136 61,718,178
2022-05-08 1,858,658 8,632,921 17,256,328 10,679,637 56,127,418 8,116,124 13,330,527 58,015,538
2022-05-09 1,862,992 7,868,856 15,149,555 9,370,326 49,256,821 7,304,147 11,702,787 51,395,671
2022-05-10 1,867,957 7,063,847 14,505,732 8,978,157 46,465,484 6,597,078 11,443,966 48,588,780
2022-05-11 1,873,972 5,668,544 11,333,232 7,294,151 37,138,310 5,461,383 10,608,911 40,366,222
2022-05-12 1,880,188 5,278,034 11,319,930 7,527,435 34,763,920 5,050,542 9,753,341 38,929,282
2022-05-13 1,886,554 5,513,923 11,908,799 7,974,383 37,378,856 5,342,800 10,508,482 41,248,386
2022-05-14 1,892,961 4,615,804 11,878,741 7,979,481 36,963,914 4,479,822 10,145,673 39,099,521
2022-05-15 1,899,371 5,098,244 13,782,259 9,704,209 38,612,156 4,897,258 12,011,210 45,493,179
2022-05-16 1,905,778 5,015,528 15,351,098 11,189,975 36,873,709 4,803,108 13,368,708 49,728,417
2022-05-17 1,912,230 5,443,403 17,448,119 12,839,946 41,591,419 5,171,446 14,786,902 55,689,816
2022-05-18 1,918,591 4,831,627 15,835,129 11,633,620 37,997,260 4,804,447 13,547,934 50,652,757
2022-05-19 1,924,950 5,051,995 16,225,841 11,866,785 39,895,569 4,969,413 13,862,470 51,976,504
2022-05-20 1,931,289 4,898,759 15,647,150 11,314,258 37,884,504 4,876,639 13,279,427 50,016,233
2022-05-21 1,937,640 5,106,622 16,761,086 12,029,939 40,106,047 5,004,865 14,171,588 53,074,101
2022-05-22 1,944,002 5,212,005 16,929,442 12,141,015 40,352,106 5,121,311 14,419,157 53,822,931
2022-05-23 1,950,438 5,142,609 17,446,267 12,545,228 41,399,483 4,976,457 14,829,710 54,940,271
2022-05-24 1,956,833 5,057,268 17,472,166 12,518,757 41,168,960 4,993,204 14,829,440 54,870,835
2022-05-25 1,963,028 5,050,561 17,263,663 12,427,987 40,146,639 4,911,964 14,681,528 54,335,703
2022-05-26 1,969,604 4,618,061 15,258,739 11,036,697 35,264,055 4,520,738 13,114,722 48,548,957
2022-05-27 1,975,998 4,450,433 14,551,135 10,552,867 33,481,007 4,318,708 12,570,318 46,443,460
2022-05-28 1,982,535 4,453,273 14,817,753 10,776,720 33,908,979 4,337,506 12,802,796 47,188,049
2022-05-29 1,988,972 4,492,985 15,688,798 11,415,697 35,866,422 4,393,571 13,441,785 49,432,835
2022-05-30 1,995,443 4,740,857 17,082,611 12,429,566 38,914,342 4,696,021 14,734,171 53,683,226
2022-05-31 2,001,782 4,882,592 17,557,356 12,660,720 39,629,966 4,752,189 15,254,737 55,107,595
2022-06-01 2,008,273 4,595,685 16,745,530 12,175,530 36,748,425 4,491,236 14,597,291 52,605,272
2022-06-02 2,014,698 4,575,532 16,911,602 12,280,079 37,009,016 4,527,606 14,688,565 52,983,386
2022-06-03 2,021,059 4,465,668 15,655,627 11,427,459 34,174,081 4,322,136 13,728,036 49,598,925
2022-06-04 2,027,513 4,449,137 15,848,848 11,565,414 34,565,469 4,350,549 13,811,670 50,025,617
2022-06-05 2,034,053 4,407,153 15,791,545 11,536,661 34,268,796 4,340,263 13,862,453 49,938,075
2022-06-06 2,040,490 4,474,010 16,291,584 11,910,789 35,089,659 4,391,089 14,227,562 51,295,033
2022-06-07 2,046,816 4,388,449 15,968,573 11,761,642 33,590,756 4,290,396 14,005,969 50,415,028
2022-06-08 2,053,305 4,306,263 15,872,801 11,707,615 33,359,732 4,227,290 13,905,651 50,019,619
2022-06-09 2,059,744 4,359,234 15,835,910 11,686,991 33,250,484 4,258,130 14,076,099 50,216,364
2022-06-10 2,066,092 4,117,787 14,183,232 10,449,312 29,651,814 4,030,011 12,632,440 45,412,782
2022-06-11 2,072,325 3,963,451 13,837,954 10,149,406 28,573,867 3,894,232 12,316,369 44,161,412
2022-06-12 2,078,699 3,771,603 12,587,494 9,236,596 26,037,108 3,673,255 11,367,864 40,636,813
2022-06-13 2,084,974 3,372,037 11,898,249 7,831,543 23,066,865 3,337,302 9,703,009 36,142,139
2022-06-14 2,091,245 3,589,270 13,209,821 9,476,166 25,683,305 3,559,449 10,736,969 40,571,674
2022-06-15 2,097,549 3,764,179 14,806,940 10,777,366 28,624,983 3,704,450 12,009,355 45,062,290
2022-06-16 2,103,874 3,440,450 12,358,705 8,915,974 24,452,010 3,377,222 10,170,473 38,262,825
2022-06-17 2,110,292 3,409,689 12,441,009 8,991,893 24,550,734 3,378,457 10,237,658 38,458,706
2022-06-18 2,116,724 3,445,679 12,332,708 8,906,555 24,393,878 3,385,252 10,142,229 38,212,423
2022-06-19 2,123,104 3,549,822 12,779,959 9,213,173 25,211,735 3,476,219 10,658,611 39,677,783
2022-06-20 2,129,497 3,622,729 13,698,153 9,626,126 26,363,349 3,554,046 11,062,858 41,563,913
2022-06-21 2,135,922 3,727,008 13,675,207 9,799,394 26,940,660 3,653,256 11,270,679 42,125,544
2022-06-22 2,142,278 3,634,993 13,363,716 9,604,004 26,269,636 3,555,480 10,997,083 41,155,276
2022-06-23 2,148,575 3,646,287 14,090,545 9,918,909 27,162,162 3,593,146 11,193,642 42,442,529
2022-06-24 2,155,139 3,752,477 14,986,389 10,567,805 28,917,147 3,721,508 11,840,803 44,868,982
2022-06-25 2,161,562 3,759,708 14,905,610 10,473,270 28,632,500 3,750,830 11,689,145 44,578,563
2022-06-26 2,168,013 3,851,061 13,132,847 9,304,393 26,522,711 3,769,934 11,280,487 41,338,722
2022-06-27 2,173,904 3,734,609 13,187,844 9,347,125 26,615,421 3,767,156 11,178,714 41,215,449
2022-06-28 2,179,705 3,730,816 12,464,915 8,860,241 25,117,020 3,710,430 10,779,657 39,546,059

Row

Sources and Notes

Please click on the Source Code link at the top of the document to see the full source code. Here is a summary:

dexTVL

  • sum of tvlUSD from the xx function in the subscanr package for R. You can also use the Karura-dex project hosted on Subquery Network with this query:
{ 
  dailyPools { 
    nodes { 
      timestamp token0 {id} token1 {id} feeRateUSD dailyTradeVolumeUSD totalTVL txCount updateAtBlock {id}  
    } 
  } 
}

LPTokenStakingTVL

  • ACA (or KAR) obtained from the py-substrate-interface using function substrate.query(module=‘Rewards’,storage_function=‘PoolInfos’, block_hash = hash)
  • mulitplied by ACA (or KAR) price for the specific block number

BridgeTVL

  • KSM (or DOT) obtained from the py-substrate-interface using function substrate.query(module=‘Tokens’,storage_function=‘TotalIssuance’, params = [{‘Token’: ‘KSM’}], block_hash = hash)
  • LKSM (or LDOT) obtained from function substrate.query(module=‘Tokens’,storage_function=‘TotalIssuance’, params = [{‘Token’: ‘LKSM’}], block_hash = hash)
  • both mulitplied by KSM (or DOT) price for the specific block number

liquidStakingTVL

  • KSM (or DOT) obtained from the py-substrate-interface using function substrate.query(module=‘Homa’,storage_function=‘TotalStakingBonded’, block_hash = hash)
  • mulitplied by KSM (or DOT) price for the specific block number

lcdotTVL (Acala only)

  • LCDOT obtained from the py-substrate-interface using function substrate.query(module=‘Tokens’,storage_function=‘TotalIssuance’, params = [{‘LiquidCrowdloan’: 13}], block_hash = hash)
  • mulitplied by DOT price for the specific block number

stableCoinTVL

{ 
  dailyCollaterals { 
    nodes { 
      collateral {id} depositAmount debitAmount depositVolumeUSD debitVolumeUSD
      depositChangedUSD debitChangedUSD debitExchangeRate timestamp txCount 
    } 
  } 
}
---
title: "Acala / Karura TVL Dashboard"
output:
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    social: menu
    source_code: embed
params:
  network: Karura
  window: 7
  
---

```{css custom1, echo=FALSE}
.dataTables_scrollBody {
    max-height: 100% !important;
}
```

```{r global, include=FALSE}
library(knitr)
knitr::opts_chunk$set(
  message = FALSE,
  warning = FALSE,
  comment = "#>"
)

library(ggplot2)
library(kableExtra)
library(formattable)
library(lubridate)
library(flexdashboard)
library(DT)
library(subscanr)
library(formattable)
library(ghql)
x <- GraphqlClient$new()

# Helper function to concat
`%+%` <- function(a, b) paste0(a, b)

window = params$window
# window <- today() - as.Date("2021-12-31") + 1
network = params$network

# Liquidity Pool TVL ($3.72M) = totalDefiTvl = totalDexTvl + totalDexLockedTvl + homaLocked + stableCoinTvl
dex <- getDailyPools_acala_dex(network, window) %>%
  setorder(Date, pair)

dailyTVL <- dex[, .(max(updateAtBlock.id), sum(tvlUSD)), by = Date] %>%
  setnames(c("V1","V2"), c("Block","dexTVL"))

library(reticulate)
# use_python("/opt/homebrew/bin/python3.9")
```

```{python, include=FALSE}
from substrateinterface import SubstrateInterface

import pandas as pd

def getTotalIssuanceKSM():
    url = 'wss://karura.polkawallet.io'
    substrate = SubstrateInterface(url)
    hash = substrate.get_block_hash(block_id)
    timestamp = substrate.query(module='Timestamp',storage_function='Now',block_hash=hash).value
  
    # Issuance
    ksm = substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'Token': 'KSM'}], block_hash = hash)
    lksm = substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'Token': 'LKSM'}], block_hash = hash)
    result = substrate.query('AcalaOracle', 'Values', params = [{'Token': 'KSM'}], block_hash = hash)
  
    # homa = substrate.query(module='Homa',storage_function='TotalStakingBonded', block_hash = hash)
    try:
        homa = substrate.query_map(module='Homa',storage_function='StakingLedgers', block_hash = hash)
        amount = 0
        for res in homa:
            amount += res[1].value['bonded']
            
        # LKSM to KSM ratio
        ratio = lksm.value / amount 

    except:
        amount = 0
        # LKSM to KSM ratio
        ratio = 8.5
    
    # Build price DataFrame
    p = substrate.query('AcalaOracle', 'Values', params = [{'Token': 'KSM'}], block_hash = hash)
    price = p.value['value'] / 10**18
  
    bridge = (float(ksm.value / 10**12) + float(lksm.value / 10**12 / ratio)) * price
    liquidKSM = float(amount / 10**12) * price
    crowdloanTVL = (501137661910050505 / 10**12) * price
    return [bridge, liquidKSM, crowdloanTVL, block_id, ratio]

def getOraclePrices():
    if r.network=="Karura":
        url = 'wss://karura.polkawallet.io'
    else:
        url = 'wss://acala-rpc-0.aca-api.network'
      
    substrate = SubstrateInterface(url)
    hash = substrate.get_block_hash(block_id)
    timestamp = substrate.query(module='Timestamp',storage_function='Now',block_hash=hash).value
    p = substrate.query_map('AcalaOracle', 'Values', block_hash = hash)
    data = []
    for res in p:
        outi = {"token": str(res[0].value), "price": res[1].value['value'] / 10**18}
        data.append(outi)
    
    out = pd.DataFrame(data)
    return out
 
 
def getRewards():
    if r.network=="Karura":
        url = 'wss://karura.polkawallet.io'
    else:
        url = 'wss://acala-rpc-0.aca-api.network'
      
    substrate = SubstrateInterface(url)
    hash = substrate.get_block_hash(block_id)
    timestamp = substrate.query(module='Timestamp',storage_function='Now',block_hash=hash).value
  
    data = []
    rewards = substrate.query_map(module='Rewards',storage_function='PoolInfos', block_hash = hash)
    for res in rewards:
        if res[0][0] == 'Dex':
            pair = res[0].value['Dex']['DexShare']
            lp = substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'DexShare': pair}], block_hash = hash)
            legs = substrate.query(module='Dex',storage_function='LiquidityPool', params = [pair], block_hash = hash)
            outi = {"pair0": str(pair[0]), "pair1": str(pair[1]), "lp": str(lp.value), "leg0": str(legs[0].value), "leg1": str(legs[1].value)}
            data.append(outi)
    
    out = pd.DataFrame(data)
    return out

def getTotalIssuanceDOT():
    url = 'wss://acala-rpc-0.aca-api.network'
    substrate = SubstrateInterface(url)
    hash = substrate.get_block_hash(block_id)
    timestamp = substrate.query(module='Timestamp',storage_function='Now',block_hash=hash).value
  
    # Total Issuance data
    dot = substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'Token': 'DOT'}], block_hash = hash)
    ldot = substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'Token': 'LDOT'}], block_hash = hash)
    lcdot = substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'LiquidCrowdloan': 13}], block_hash = hash)
    
    # homa = substrate.query(module='Homa',storage_function='TotalStakingBonded', block_hash = hash)
    try:
        homa = substrate.query_map(module='Homa',storage_function='StakingLedgers', block_hash = hash)
        amount = 0
        for res in homa:
            amount += res[1].value['bonded']
            
        # LKSM to KSM ratio
        ratio = ldot.value / amount 

    except:
        amount = 0
        # LDOT to DOT ratio
        ratio = 10
    
    # Build price DataFrame
    tmp = []
    p = substrate.query_map('AcalaOracle', 'Values', block_hash = hash)
    outi = {"id": {'Token': 'AUSD'}, "price": 1}
    tmp.append(outi)
    for res in p:
      outi = {"id": res[0].value, "price": res[1].value['value'] / 10**18}
      tmp.append(outi)
      if res[0].value=={'Token': 'DOT'}:
        outi = {"id": {'LiquidCrowdloan': 13}, "price": res[1].value['value'] / 10**18 / 1.4}
        tmp.append(outi)
        outi = {"id": {'Token': 'LDOT'}, "price": res[1].value['value'] / 10**18 / ratio}
        tmp.append(outi)
  
    # Price lookup function
    p = substrate.query('AcalaOracle', 'Values', params = [{'Token': 'DOT'}], block_hash = hash)
    price = p.value['value'] / 10**18
    
    # Decimals lookup function
    tmp = [{'id': {'Token': 'ACA'}, 'decimals': 12}, {'id': {'Token': 'DOT'}, 'decimals': 10}, {'id': {'Token': 'LDOT'}, 'decimals': 10}, {'id': {'LiquidCrowdloan': 13}, 'decimals': 10}, {'id': {'Token': 'AUSD'}, 'decimals': 12}]
    decimals = pd.DataFrame(tmp)
    def getDecimals(token):
      return int(decimals[decimals['id'] == token]['decimals'])        
  
    bridge = (float(dot.value / 10**10) + float(ldot.value / 10**10 / ratio)) * price
    liquidDOT = float(amount / 10**10) * price
    lcDOT = float(lcdot.value / 10**10) * price
    crowdloanTVL = (325159802323576263 / 10**10) * price
    return [bridge, liquidDOT, crowdloanTVL, lcDOT, block_id, ratio]

```



```{r tvl, cache = TRUE, include=FALSE}

# dailyTVL[, M := month(Date) %+% year(Date)]
# dailyTVL[, maxDate := max(Date), by = M]
# dailyTVL <- dailyTVL[Date == maxDate]

# LP Token Staking TVL = totalDexTvl = useTotalDexPoolTVL()
# totalDexLockedTvl = useTotalStaking() = api.query.dex?.liquidityPool
# KSM Bridge TVL = totalIssuanceKSM = useTotalIssuance('KSM') = api.query.tokens?.totalIssuance
dailyTVL[, bridgeTVL := 0]
# Liquid KSM TVL = totalLocked in Homa = useState()
dailyTVL[, liquidStakingTVL := 0]
# homeLocked = totalStaking * price
dailyTVL[, crowdloanTVL := 0]
dailyTVL[, LPTokenStakingTVL := 0]
if (tolower(network) == "acala") dailyTVL[, lcdotTVL := 0]

for (i in 1:nrow(dailyTVL)) {
  py_run_string("block_id = " %+% dailyTVL$Block[i])
  if (tolower(network) == "karura") {
    tmp = py$getTotalIssuanceKSM()
  } else {
    tmp = py$getTotalIssuanceDOT()
    dailyTVL$lcdotTVL[i] <- tmp[4]
  }
  dailyTVL$bridgeTVL[i] <- tmp[1]
  dailyTVL$liquidStakingTVL[i] <- tmp[2]
  dailyTVL$crowdloanTVL[i] <- tmp[3]
  
  # LPTokenStakingTVL 
  rewards1 <- py$getRewards()
  rewards <- as.data.table(rewards1)
  # sort(unique(c(rewards$pair0, rewards$pair1)))
  rewards[, pair0 := fixToken(pair0)]
  rewards[, pair1 := fixToken(pair1)]
  rewards <- merge(rewards, tokens, by.x = 'pair0', by.y="Token")
  setnames(rewards, "decimals", "decimals0")
  rewards[, Name := NULL]
  rewards <- merge(rewards, tokens, by.x = 'pair1', by.y="Token")
  setnames(rewards, "decimals", "decimals1")
  rewards[, Name := NULL]
  rewards[, decimals0 := as.numeric(decimals0)]
  rewards[, decimals1 := as.numeric(decimals1)]
  rewards[, lpDecimals := 12]
  rewards[pair0=='DOT' & pair1=='LCDOT', lpDecimals := 10]
  rewards[, lp := as.numeric(lp) / 10**lpDecimals]
  rewards[, leg0 := as.numeric(leg0) / 10**decimals0]
  rewards[, leg1 := as.numeric(leg1) / 10**decimals1]
  
  price = py$getOraclePrices() %>%
    as.data.table
  price[, token := fixToken(token)]
  
  rewards <- merge(rewards, price, by.x = "pair0", by.y="token", all.x = TRUE)
  setnames(rewards, "price", "price0")
  rewards <- merge(rewards, price, by.x = "pair1", by.y="token", all.x = TRUE)
  setnames(rewards, "price", "price1")
  rewards[pair0 %in% c('KUSD', "AUSD"), price0 := 1]
  rewards[pair1 %in% c('KUSD', "AUSD"), price1 := 1]
  rewards[, tvl := leg0 * price0 + leg1 * price1]
  rewards[is.na(tvl), tvl := (leg0 * price0) * 2]
  rewards[is.na(tvl), tvl := (leg1 * price1) * 2]
  rewards[, lpPrice := tvl / lp]  
  dailyTVL$LPTokenStakingTVL[i] <- sum(rewards$tvl, na.rm = TRUE)

}



# stableCoinTvl
# const stableCoinTVL = useTotalLocked(); = api.query.loans?.totalPositions
collateral <- getLoansDailyCollateral_acala_loan(network, window, staging = FALSE) %>%
  setorder(Date, collateral.id)
stableCoinTvl <- collateral[, sum(depositVolumeUSD), by = Date] %>%
  setnames("V1", "stableCoinTVL")
dailyTVL <- merge(dailyTVL, stableCoinTvl, by = "Date", all.x = TRUE)

# If monthly, remove these fields
# try(dailyTVL[, M := NULL])
# try(dailyTVL[, maxDate := NULL])

# Make columns numeric
for (col in names(dailyTVL)[-1]) set(dailyTVL, j=col, value=as.numeric(dailyTVL[[col]])) 
if (tolower(network) == "acala") {
  dailyTVL[, OverallTVL := dexTVL + LPTokenStakingTVL + bridgeTVL + liquidStakingTVL + lcdotTVL + stableCoinTVL]
} else {
  dailyTVL[, OverallTVL := dexTVL + LPTokenStakingTVL + bridgeTVL + liquidStakingTVL + stableCoinTVL]
}

history <- fread(file = network %+% "_TVL.csv")
history[, Date := as.Date(Date)]
minDate <- min(dailyTVL$Date)
comb <- rbind(history[Date < minDate], dailyTVL)
fwrite(x = comb, file = network %+% "_TVL.csv")
dailyTVL <- comb

```

# `r network` {.tabset}

Row
----

### Components of Total Value Locked

```{r k_plot1}

if (tolower(network) == "acala") {
  dat <- melt(data = dailyTVL[, .(Date, dexTVL, LPTokenStakingTVL, bridgeTVL, liquidStakingTVL, lcdotTVL, stableCoinTVL)], 
            id.vars = "Date",
            value.name = "TVL")
  cols <- c('dexTVL', 'LPTokenStakingTVL', 'bridgeTVL', 'liquidStakingTVL', 'LCDOTTVL', 'stableCoinTVL')
} else {
  dat <- melt(data = dailyTVL[, .(Date, dexTVL, LPTokenStakingTVL, bridgeTVL, liquidStakingTVL, stableCoinTVL)], 
            id.vars = "Date",
            value.name = "TVL")
  cols <- c('dexTVL', 'LPTokenStakingTVL', 'bridgeTVL', 'liquidStakingTVL', 'stableCoinTVL')
  
}
dat[, TVL := TVL / 1e6]
 
# Stacked
ggplot(dat, aes(fill=variable, y=TVL, x=Date)) + 
    geom_bar(position="stack", stat="identity") +
    ggtitle(label="Components of Total Value Locked") + 
    ylab("Totval Value Locked (in millions USD)")

```

Row
----

### Overall Total Value Locked (TVL)

* The Overall TVL in the table below does not includes the Crowdloan TVL, which also seems to be the case on the stats.`r network`.network page.

```{r k_tvl}

knitr::kable(dailyTVL, escape = FALSE, format.args = list(big.mark = ",")) %>%
  kable_styling()

```



Row
----

### Sources and Notes

Please click on the *Source Code* link at the top of the document to see the full source code.  Here is a summary:

#### dexTVL 

- sum of tvlUSD from the xx function in the [subscanr](https://github.com/rogerjbos/subscanr) package for R.  You can also use the [Karura-dex](https://explorer.subquery.network/subquery/AcalaNetwork/karura-dex) project hosted on Subquery Network with this query:
```
{ 
  dailyPools { 
    nodes { 
      timestamp token0 {id} token1 {id} feeRateUSD dailyTradeVolumeUSD totalTVL txCount updateAtBlock {id}  
    } 
  } 
}
```

#### LPTokenStakingTVL
- ACA (or KAR) obtained from the [py-substrate-interface](https://github.com/polkascan/py-substrate-interface) using function *substrate.query(module='Rewards',storage_function='PoolInfos', block_hash = hash)*
- mulitplied by ACA (or KAR) price for the specific block number

#### BridgeTVL
- KSM (or DOT) obtained from the [py-substrate-interface](https://github.com/polkascan/py-substrate-interface) using function *substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'Token': 'KSM'}], block_hash = hash)*
- LKSM (or LDOT) obtained from function *substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'Token': 'LKSM'}], block_hash = hash)*
- both mulitplied by KSM (or DOT) price for the specific block number

#### liquidStakingTVL
- KSM (or DOT) obtained from the [py-substrate-interface](https://github.com/polkascan/py-substrate-interface) using function *substrate.query(module='Homa',storage_function='TotalStakingBonded', block_hash = hash)*
- mulitplied by KSM (or DOT) price for the specific block number

#### lcdotTVL (Acala only)
- LCDOT obtained from the [py-substrate-interface](https://github.com/polkascan/py-substrate-interface) using function *substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'LiquidCrowdloan': 13}], block_hash = hash)*
- mulitplied by DOT price for the specific block number

#### stableCoinTVL
- sum of depositVolumeUSD from the *getLoansDailyCollateral_acala_loan* function in the [subscanr](https://github.com/rogerjbos/subscanr) package for R.  You can also use the [Karura-loan]https://explorer.subquery.network/subquery/AcalaNetwork/karura-loan) project hosted on Subquery Network with this query:
```
{ 
  dailyCollaterals { 
    nodes { 
      collateral {id} depositAmount debitAmount depositVolumeUSD debitVolumeUSD
      depositChangedUSD debitChangedUSD debitExchangeRate timestamp txCount 
    } 
  } 
}
```